'use strict'
exports.main = async (event, context) => {
  console.log("🚀 ~ file: index.js:3 ~ exports.main= ~ event:", event)
  try {
    const fileID = await uniCloud.uploadFile({
      cloudPath: `avatar/${event.filename}`, // 将头像图片存储在 avatar 目录下
      fileContent: Buffer.from(event.file, 'base64'), // 将头像图片的 Base64 编码转换为 Buffer
    })
    console.log("🚀 ~ file: index.js:8 ~ exports.main= ~ fileID:", fileID)

    return {
      fileID,
    }
  } catch (error) {
    console.error(error)
    return {
      error: error.message,
    }
  }
}
